home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: redoCheckPage.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:58 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "latch.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "log.h"
- #include "pool.h"
- #include "volume.h"
- #include "logrecs.h"
- #include "trans.h"
- #include "openlog.h"
- #include "bitmap.h"
- #include "bf_extfuncs.h"
- #include "bm_extfuncs.h"
- #include "trans_extfuncs.h"
- #include "redo_intfuncs.h"
- #include "logaction.h"
- #include "util_funcs.h"
- #include "thread_globals.h"
- #include "bf_globals.h"
- #include "log_globals.h"
- #include "log_extfuncs.h"
- #include "sm_macro.h"
-
-
- BOOL
- redoCheckPage (
-
- LOGRECORDHDR *record,
- GROUPLINK **returnGroupLink, /* return pointer to the page */
- PAGETYPE pageType
- )
- {
-
- PID *pid;
- DIRTYPAGEINFO *dirtyInfo;
- PAGE2SIZE page2size;
- LRC *pageLRC;
- GROUPLINK *groupLink;
-
- /*
- * get a pointer to the page for the record
- */
- pid = &(record->actionPid);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
-
- /*
- * check to see if the page is in the dirty page list
- */
- if ((dirtyInfo = searchDirtyPageTable(pid)) == NULL) {
-
- /*
- * don't need to redo
- */
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty page not present"));
- return(FALSE);
- }
-
- /*
- * check to see if the lrc on the page is greater than
- * the lrc in the log record.
- * Also check the lsn for the case of pages which never made it
- * back from the client.
- */
- if (CHECK_PAGE_LRC_LESS_DIRTYINFO(record->actionLRC, record->recordLSN, dirtyInfo)) {
-
- /*
- * don't need to redo
- */
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty info page lrc later"));
- return(FALSE);
- }
-
- /*
- * Get the page size for this page type
- */
- switch (pageType) {
- case PAGE_SLOTTED: page2size = SLOTTED_PAGE2SIZE;
- break;
- case PAGE_LARGENODE: page2size = LG_PAGE2SIZE;
- break;
- case PAGE_LARGEDATA: page2size = LGDATA_PAGE2SIZE;
- break;
- case PAGE_INDEX: page2size = BTREE_PAGE2SIZE;
- break;
- case PAGE_INDEXDESC: page2size = INDEXDESC_PAGE2SIZE;
- break;
- default:
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * read in the page
- */
- if ((groupLink = bf_ReadPage(UserBufGroup, pid, page2size, BF_SEM)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * Get the lrc for this page type
- */
- switch (pageType) {
- case PAGE_SLOTTED:
- pageLRC = &( ((SLOTTEDPAGE*) groupLink->bufFrame)->header.lrc );
- SM_ASSERT(LEVEL_1, !CHECK_SLOTTED_MAGIC((SLOTTEDPAGE*) groupLink->bufFrame));
- break;
- case PAGE_LARGENODE:
- pageLRC = &( ((LGNODE*) (groupLink->bufFrame))->header.lrc );
- CHECK_LARGENODE_MAGIC((LGNODE*) groupLink->bufFrame);
- break;
- case PAGE_LARGEDATA:
- pageLRC = &( ((LGDATAPAGE*) groupLink->bufFrame)->header.lrc );
- CHECK_LGDATAHDR_MAGIC((LGDATAPAGE*) groupLink->bufFrame);
- break;
- case PAGE_INDEX:
- pageLRC = (LRC*)groupLink->bufFrame; /* lrc at beginning of page */
- break;
- case PAGE_INDEXDESC:
- pageLRC = & ( ((INDEXDESCPAGE *) groupLink->bufFrame)->lrc );
- break;
- default:
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * See if the operation has been performed
- */
- if (compareLRC( &(record->actionLRC), pageLRC ) <= 0) {
-
- /*
- * don't need to redo
- */
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty info page lrc later"));
- dirtyInfo->lrc = *pageLRC;
-
- /*
- * Release the page and return
- */
- signalSemaphore( &(groupLink->pageHash->semaphore) );
- bf_UnfixPage(groupLink, BF_DEFAULT, FALSE);
- return(FALSE);
- }
-
- /*
- * Set up the firstLSN/LRC for the page
- */
- DEPEND_LOG(groupLink->pageHash, 0, &(record->recordLSN), &(record->actionLRC));
-
- /*
- * The operation needs to be redone. Make sure that the
- * LRC difference is 1 (ie. nothing has been skipped).
- */
- #ifdef DEBUG
- #ifdef INIT_LRC_IS_LSN
- /*
- * This cannot be checked when lrc's are not always incremented
- */
- #else
- {
- LRC tempLRC;
- tempLRC = pageLRC;
- INCREMENT_LRC(&tempLRC);
- SM_ASSERT(LEVEL_1, compareLRC(&(record->actionLRC), &tempLRC) == 0);
- }
- #endif /* INIT_LRC_IS_LSN */
- #endif
-
- /*
- * Return the page
- */
- *returnGroupLink = groupLink;
- return(TRUE);
- }
-